﻿namespace EyeOpen.Editing.Windows
{
	using System;
	using System.Collections.Generic;

	public class DependencyResolverImplementation
	{
		private static readonly IDictionary<Type, object> registeredDictionary =
			new Dictionary<Type, object>();

		public T Resolve<T>()
		{
			var type = typeof(T);

			if (!registeredDictionary.ContainsKey(type))
			{
				return default(T);
			}

			return (T)registeredDictionary[type];
		}

		public T Register<T>(object obj)
		{
			var type = typeof(T);

			if (!registeredDictionary.ContainsKey(type))
			{
				registeredDictionary.Add(type, obj);
			}

			return (T)registeredDictionary[type];
		}
	}
}